const arr1 = [1, 2, 3, NaN];
const arr2 = [3, 4, 5, NaN];

function mergeArray(arr1, arr2) {
  // 克隆
  const cloneArr1 = arr1.slice(0);
  let v;
  for (let i = 0; i < arr2.length; i++) {
    v = arr2[i];
    // 按位非，反转操作数的位，表象是对后面数字求负减一
    // 当数组中不存在此项 indexOf 返回 -1 按位非得 0 不走 if 逻辑
    // 如果两个数组都包含NaN，想要去重可使用includes
    if (cloneArr1.includes(v)) {
      continue;
    }
    cloneArr1.push(v);
  }
  return cloneArr1;
}

console.log(mergeArray(arr1, arr2));
